package cn.kgc.controller;


import cn.kgc.dtos.Dto;
import cn.kgc.pojo.ItripUserLinkUser;
import cn.kgc.service.ItripHotelOrderService;
import cn.kgc.service.linkUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/api")
public class LinkUserController {

    @Resource
    private linkUserService linkUserService;

    @Resource
    private ItripHotelOrderService itripHotelOrderService;
    /**
     * 查询旅客
     * @param linkUserName
     * @return
     */
    @RequestMapping(value = "/userinfo/queryuserlinkuser",method = RequestMethod.POST)
    public Dto queryuserlinkuser(@RequestBody ItripUserLinkUser linkUserName, HttpServletRequest request){
        String token=request.getHeader("token");
        return linkUserService.selectByname(linkUserName.getLinkUserName(),token);
    }

    /**
     * 添加旅客
     * @param itripUserLinkUser
     * @return
     */
    @RequestMapping(value = "/userinfo/adduserlinkuser",method = RequestMethod.POST)
    public  Dto add(@RequestBody ItripUserLinkUser itripUserLinkUser,HttpServletRequest request){
    return  linkUserService.insertlinkUser(itripUserLinkUser,request.getHeader("token"));
    }

    /**
     * 删除旅客
     * @param ids
     * @return
     */
    @RequestMapping("/userinfo/deluserlinkuser")
    public  Dto del(int [] ids){
        return  linkUserService.deletelinkUser(ids);
    }

    /**
     * 修改旅客
     * @param itripUserLinkUser
     * @param request
     * @return
     */
    @RequestMapping(value = "/userinfo/modifyuserlinkuser",method = RequestMethod.POST)
    public Dto update(@RequestBody ItripUserLinkUser itripUserLinkUser,HttpServletRequest request){
        return linkUserService.updatelinkUser(itripUserLinkUser,request.getHeader("token"));
    }


}
